package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName  GlobalExceptionHandler
 * Author  XiaojianOne
 * Date  2025/2/27 10:57
 * Version  8.0
 */

@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Result handle(Exception e){
        e.printStackTrace();

        return Result.fail();
    }


    @ResponseBody
    @ExceptionHandler(LeaseException.class)
    public Result handle(LeaseException e){
        e.printStackTrace();

        return Result.fail(e.getCode(),e.getMessage());
    }
}
